package com.stox.ui.javafx.core.workspace;

import javafx.scene.control.ChoiceBox;
import javafx.util.StringConverter;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.stox.dto.Workspace;

@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class WorkspaceChoiceBox extends ChoiceBox<Workspace> {

	public WorkspaceChoiceBox() {
		Workspace workspace = new Workspace();
		workspace.setId(1l);
		workspace.setName("Default Workspace");
		getItems().addAll(workspace);
		getSelectionModel().select(0);
		
		setConverter(new StringConverter<Workspace>(){
			@Override
			public Workspace fromString(String arg0) {
				return null;
			}
			
			@Override
			public String toString(Workspace workspace) {
				return workspace.getName();
			}
		});
	}	
}